<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="http://www.thymeleaf.org">
<head  th:include="_header_include::frag(~{::title},~{::style},~{})">
    <title>新建资源</title>
    <meta charset="UTF-8">
    <style>
        .addCustomer .borderbox .el-row{width: 1100px;margin:0 auto;}
        .addCustomer .dialogForm .borderbox .el-row{width: 830px;margin:0 auto;}
        .templateBox{cursor: pointer;}
        .elCardBox{border:0;}
        .elCardBox .el-card__body{height: 115px;}
        .elCardBox .title{margin-bottom: 15px;padding: 0 30px;}
        .elCardBox ul{overflow: hidden;width: 550px;margin: 0 auto;}
        .elCardBox ul li{float: left;width: 125px;height: 32px;line-height: 32px;background: rgba(92,107,232,0.9);margin-right:10px;text-align: center;border-radius: 4px;color: #fff;margin-bottom: 10px;font-size: 13px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
        .elCardBox ul li.bg1{background: rgba(74,182,92,0.9);}
        .elCardBox ul li.bg2{background: rgba(230,162,60,0.9);}
        .elCardBox ul li.bg3{background: rgba(227,116,112,0.9);}
    </style>
</head>
<body>
<div  v-loading="loading" id="addCustomer" class="addCustomer mainPadding" style="display: none;"> 
    <el-breadcrumb separator="/" class="elBreadcrumb marginB20">
        <el-breadcrumb-item>Home</el-breadcrumb-item>
        <el-breadcrumb-item>资源管理</el-breadcrumb-item>
        <el-breadcrumb-item>新建资源</el-breadcrumb-item>
    </el-breadcrumb> 
    
    <el-row class="borderbox">
        <div class="inforTitle">新建资源</div>
        <el-form :model="form" :rules="rules" ref="form" class="padding20">
        	<div class="marginB20 fs16 paddingT20">基本信息 
        			<el-button type="primary"  @click="chooseTemplate">选择模板</el-button>
        	</div>
            <div class="borderbox padding20">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="客户姓名：" prop="cusName" :label-width="formLabelWidth">
                            <span style="position: absolute;left: -73px;top: 4px;color: #f56c6c;z-index: 1;">*</span>
                           <el-input v-model="form.cusName"  placeholder="未知" autocomplete="off" maxLength="10" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="性别：" :label-width="formLabelWidth">
                           <el-select v-model="form.sex" placeholder="请选择" style="width: 260px;">
                                <el-option
                                    v-for="item in optsex"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="手机号：" prop="phone" :label-width="formLabelWidth">
                            <span style="position: absolute;left: -62px;top: 4px;color: #f56c6c;z-index: 1;">*</span>
                            <el-input v-model.trim="form.phone" autocomplete="off" style="width: 260px;margin-right: 10px;" @keyup.native="number" @change.native="number" maxLength="30"></el-input>
                            <!-- <el-button type="primary" :disabled="isDisabled" @click="dialogFormVisible = true"><i class="el-icon-plus"></i>手机号</el-button> -->
                            <span v-if="buttonType === 'A'"> 
                                <el-button type="primary" :disabled="isDisabled" @click="dialogFormVisible = true"><i class="el-icon-plus"></i>手机号</el-button>
                            </span>
                            <span v-else-if="buttonType === 'B'">    
                                <span @click="dialogFormVisible = true" style="padding-left: 5px; color: rgb(0, 114, 255); cursor: pointer;">查看多个手机号</span>
                            </span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="微信：" prop="wechat" :label-width="formLabelWidth">
                            <span style="position: absolute;left: -50px;top: 4px;color: #f56c6c;z-index: 1;">*</span>
                            <el-input v-model.trim="form.wechat" autocomplete="off" style="width: 260px;margin-right: 10px;" maxLength="20" @keyup.native="form.wechat = form.wechat.replace(/\s+/g,'')"></el-input>
                           	<span v-if="form.wechat2 == '' && form.wechatUrl=='' ">
	                           <el-button type="primary"  @click="openWechat"><i class="el-icon-plus"></i>微信/二维码</el-button>
                            </span>
                            <span v-else="">
                                <span @click="openWechat" style="padding-left: 5px; color: rgb(0, 114, 255); cursor: pointer;">查看多个微信/二维码</span>
                            </span>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                	<el-col :span="12">
                        <el-form-item label="QQ：" prop="qq" :label-width="formLabelWidth" >
                            <span style="position: absolute;left: -45px;top: 4px;color: #f56c6c;z-index: 1;">*</span>
                            <el-input v-model.trim="form.qq" autocomplete="off" maxLength="20" @keyup.native="qqnumber" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                	<el-col :span="12">
                        <el-form-item label="邮箱：" prop="email" :label-width="formLabelWidth">
                            <span style="position: absolute;left: -50px;top: 4px;color: #f56c6c;z-index: 1;">*</span>
                            <el-input v-model.trim="form.email" autocomplete="off" maxLength="100" style="width: 260px;" @keyup.native="form.email = form.email.replace(/\s+/g,'')"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row><p style="padding-left: 120px;font-size: 14px;color: red;padding-bottom: 10px;">（手机、微信、QQ、邮箱至少填一项）</p></el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="留言时间：" :label-width="formLabelWidth">
                         <el-date-picker
                                style="width: 260px;"
                                v-model="form.messageTime"
                                type="datetime"
                                placeholder="输入留言时间">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="留言重点：" :label-width="formLabelWidth">
                            <el-input v-model="form.messagePoint" placeholder="输入留言内容" autocomplete="off"  maxLength="300" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                	<el-col :span="12">
                        <el-form-item label="搜索词：" :label-width="formLabelWidth">
                           <el-input v-model="form.searchWord" autocomplete="off" maxlength="50" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                	<el-col :span="12">
                        <el-form-item label="词根：" :label-width="formLabelWidth" prop="rootWord" >
                           <el-input  v-model="form.rootWord" autocomplete="off" maxLength="50" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="备注：" :label-width="formLabelWidth" prop="remark" >
                            <el-input  v-model="form.remark" autocomplete="off" maxLength="50" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="marginB20 fs16 paddingT20">资源信息</div>
            <div class="borderbox padding20">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="年龄：" :label-width="formLabelWidth" prop="age" >
                           <el-input type="number" v-model="form.age" autocomplete="off" maxLength="3" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="开店区域：" :label-width="formLabelWidth" style="float: left;margin-right: 10px;">
                          <el-select filterable v-model="form.province" placeholder="省" style="width: 125px;"  @change="currentProvince" clearable>
                              <el-option
                                  v-for="item in provinceArr"
                                  :key="item.name"
                                  :label="item.name"
                                  :value="item.name">
                              </el-option>
                          </el-select>
                      </el-form-item>
                      <el-form-item label="" style="float: left;">
                          <el-select filterable v-model="form.city" placeholder="市" style="width: 125px;margin-right: 10px;" @change="currentCity" clearable>
                              <el-option
                                  v-for="item in cityArr"
                                  :key="item.name"
                                  :label="item.name"
                                  :value="item.name">
                              </el-option>
                          </el-select>
                      </el-form-item>
                      <el-form-item label="" style="float: left;">
                          <el-select filterable v-model="form.district" placeholder="区/县" style="width: 125px;" clearable>
                              <el-option
                                  v-for="item in districtArr"
                                  :key="item.name"
                                  :label="item.name"
                                  :value="item.name">
                              </el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="预约回访时间：" :label-width="formLabelWidth" prop="reserveTime">
                            <el-date-picker v-model="form.reserveTime"  type="datetime" placeholder="输入客户方便联系的时间" style="width: 260px;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="资源类型：" :label-width="formLabelWidth" prop="type">
                            <el-select v-model="form.type" placeholder="请选择" style="width: 260px;">
                                <el-option
                                    v-for="item in typeOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="资源类别：" :label-width="formLabelWidth" prop="category">
                            <el-select v-model="form.category" placeholder="请选择" style="width: 260px;" @change="categoryChange" clearable filterable>
                                <el-option
                                    v-for="item in categoryOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                
                    <el-col :span="12">
                        <el-form-item label="广告位：" :label-width="formLabelWidth" prop="sourceType">
                            <el-select v-model="form.sourceType" placeholder="请选择" style="width: 260px;" clearable filterable :disabled="sourceTypeDisabled">
                                <el-option
                                    v-for="item in sourceTypeOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="媒介：" :label-width="formLabelWidth" prop="source">
                            <el-select v-model="form.source" placeholder="请选择" style="width: 260px;" clearable filterable>
                                <el-option
                                    v-for="item in sourceOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>               
                    <el-col :span="12">
                        <el-form-item label="资源项目(项目名称)：" :label-width="formLabelWidth" prop="projectId">
                            <el-select v-model="form.projectId" placeholder="请选择" style="width: 260px;" clearable filterable :disabled="projectDisabled">
                                <el-option
                                    v-for="item in projectOptions"
                                    :key="item.id"
                                    :label="item.projectName"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>                
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="行业类别："  :label-width="formLabelWidth">
                            <el-select v-model="form.industryCategory" clearable placeholder="请选择" style="width: 260px;" filterable>
                                <el-option
                                    v-for="item in industryCategoryOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="URL地址：" :label-width="formLabelWidth">
                            <el-input v-model="form.urlAddress" autocomplete="off" maxlength="2000" style="width: 260px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="账户名称：" :label-width="formLabelWidth">
                            <el-select v-model="form.accountName"  placeholder="请选择" style="width: 260px;" clearable filterable>
                                <el-option
                                    v-for="item in accountNameOptions"
                                    :key="item.value"
                                    :label="item.name"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="padding20 f-tac">            
                <el-button type="primary" @click="openViewForm('form')">提交</el-button>
                <el-button  @click="rebackMV">取 消</el-button>
            </div> 
        </el-form> 
    </el-row>

    <!-- dialog -->
    <el-dialog title="添加手机号" :visible.sync="dialogFormVisible">
        <button type="button" aria-label="Close" class="el-dialog__headerbtn" style="position: absolute;z-index: 9;background: #fff;border-radius: 50%;" @click="clearDialog"><i class="el-dialog__close el-icon el-icon-close"></i></button>
        <el-form :model="dynamicValidateForm" ref="dynamicValidateForm">
            <el-form-item  
                :label-width="formLabelWidth"
                v-for="(domain, index) in dynamicValidateForm.domains"
                :label="'手机号' + (parseInt(index)+2) + ':'"
                :key="domain.key"
                :prop="'domains.' + index + '.value'"
                :rules="{
                    required: true, message: '手机号不能为空', trigger: 'blur',
                }"
            >
                <el-input v-model.trim="domain.value" maxLength="30" @keyup.native="phoneNumber" @change.native="phoneNumber" style="width: 300px;margin-right: 10px;"></el-input>
                <el-button type="danger" @click.prevent="removeDomain(domain)" v-show="deleteShow">删除</el-button>
            </el-form-item>
        </el-form>
        <div slot="footer" class="f-tac">            
            <el-button type="primary" @click="submitDialogForm('dynamicValidateForm')"  >提 交</el-button>
            <el-button type="success" @click="addDomain">添加更多手机号</el-button>
        </div>
    </el-dialog>    
    <el-dialog title="添加微信" :visible.sync="wechatVisible" width="540px">
        <template>
            <el-form :model="wechatForm" ref="wechatForm" > 
              <el-form-item label="微信2：" :label-width="formLabelWidth1" >
                  <el-input v-model.trim="wechatForm.wechat2" placeholder="" maxLength="20" style="width: 290px;" @keyup.native="wechatForm.wechat2 = wechatForm.wechat2.replace(/\s+/g,'')"></el-input>
              </el-form-item>
              <el-form-item label="添加微信二维码：" :label-width="formLabelWidth1" prop="fileList">
              	<el-upload
                    class="upload-demo"
                    :action="uploadOssHost"
                    ref="refundApplyImgUpload"
                    :on-preview="handlePreview"
                    :on-remove="handleRemove"
                    :on-success="handleSuccess"
                    :on-error="handleError"
                    :before-upload="handleBefore"
                    accept=".jpg,.png"
                    multiple
                    :data="uploadParamData"
                    :limit='1'
                    :on-change="selectFile"
                    :on-exceed="handleExceed"
                    :auto-upload="false"
                    :file-list="fileList">
                    <el-button slot="trigger" size="small" type="primary">选择图片</el-button>
                     <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传</el-button>
                    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2MB</div>
                </el-upload>
              </el-form-item>
              <el-form-item label="" :label-width="formLabelWidth1" >
                  <img v-show="wechatForm.wechatUrl!=''" :src="wechatForm.wechatUrl" width="290px" style="border-radius:6px;">
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="wechatSumbit()">提 交</el-button>
                <el-button  @click="wechatVisible=false">取 消</el-button>
            </div>
        </template>
    </el-dialog>    
    <!-- 选择模板 -->
    <!-- dialog -->
    <el-dialog title="选择资源模板" :visible.sync="chooseVisible" width="1200px">
        <el-row class="marginB20 greybg padding20" style="padding-bottom: 0;">
            <el-form :inline="true" :model="clueTemplateSearchForm" class="demo-form-inline" ref="clueTemplateSearchForm">
        	    <el-form-item label="资源项目:" >
                    <el-select v-model="clueTemplateSearchForm.clueProjectId" placeholder="资源项目" clearable filterable>
                        <el-option
                            v-for="item in projectOptions"
                            :key="item.id"
                            :label="item.projectName"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>                
                <el-form-item label="资源类别:" >
                    <el-select v-model="clueTemplateSearchForm.category" placeholder="资源类别" clearable>
                        <el-option
                            v-for="item in categoryOptions"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item> 
                <el-form-item label="媒介:" >
                    <el-select v-model="clueTemplateSearchForm.source" placeholder="媒介" clearable filterable>
                        <el-option
                            v-for="item in sourceOptions"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="广告位:" >
                    <el-select v-model="clueTemplateSearchForm.sourceType" placeholder="广告位" clearable filterable>
                        <el-option
                            v-for="item in sourceTypeOptions"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>              
                <el-form-item label="资源类型:" >
                    <el-select v-model="clueTemplateSearchForm.type" placeholder="资源类型" clearable>
                        <el-option
                            v-for="item in typeOptions"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item  prop="name" label="模板名称:" style="margin-right: 6px">
                    <el-input v-model="clueTemplateSearchForm.name" placeholder="模板名称" class="input-with-select" style="width: 175px;"></el-input>
                </el-form-item>
                <el-button icon="el-icon-search" type="primary" @click="searchTable()">搜索</el-button>
            </el-form> 
        </el-row>
        <el-row :gutter="12">            
            <el-col :span="12" v-for="item in dataTable">
                <el-card shadow="always" class="elCardBox marginB20">
                    <div class="templateBox" @click="clickTemplate(item)">
                        <div class="title fs16">{{item.name}}</div>
                        <ul>
                            <li v-if="item.clueProjectName">{{item.clueProjectName}}</li>
                            <li v-if="item.source" class="bg1">{{item.sourceName}}</li>
                            <li v-if="item.sourceType" class="bg2">{{item.sourceTypeName}}</li>
                            <li v-if="item.category" class="bg3">{{item.categoryName}}</li>
                            <li v-if="item.type">{{item.typeName}}</li>
                            <li v-if="item.searchWord" class="bg1">{{item.searchWord}}</li>
                            <li v-if="item.classification" class="bg2">{{item.classificationName}}</li>
                        </ul>
                    </div>                    
                </el-card>
            </el-col>
        </el-row>
        <!-- <el-table  ref="multipleTable" tooltip-effect="dark" border @row-dblclick="clickTemplate" style="width: 100%"  :data="dataTable" >
            <el-table-column align="center" prop="name" label="模板名称">
              	<template slot-scope="scope">
                    <el-button @click="clickTemplate(scope.row)" type="text" size="small">{{scope.row.name}}</el-button>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="clueProjectName" label="资源项目"></el-table-column>
            <el-table-column align="center" prop="source" label="媒介" :formatter="transformSource"></el-table-column>
            <el-table-column align="center" prop="sourceType" label="广告位" :formatter="transformSourceType"></el-table-column>
            <el-table-column align="center" prop="category" label="资源类别" :formatter="transformCategory" width="120"></el-table-column>
            <el-table-column align="center" prop="type" label="资源类型" :formatter="transformType" width="120"></el-table-column>
        </el-table> -->
        <table-pagination :pager="pager" @change="searchTable"></table-pagination>
    </el-dialog>
    <!-- dialog -->
	<el-dialog title="确认资源信息" :visible.sync="viewFormVisible" width="870px">
		<el-form :model="viewForm" ref="viewForm" class="marginB20 dialogForm" >
			<div class="fs16 marginB10">基本信息</div>
			<div class="borderbox" style="padding:10px 0;">
				<el-row>
					<el-col :span="12">
						<el-form-item label="客户姓名：" :label-width="formLabelWidth"> {{viewForm.cusName}} </el-form-item>
					</el-col>
                    <el-col :span="12"> 
                        <el-form-item label="性别：" :label-width="formLabelWidth"> {{viewForm.sexName}}</el-form-item> 
                    </el-col> 
					<el-col :span="12">
						<el-form-item label="手机号：" :label-width="formLabelWidth"> {{viewForm.phone}} 
						</el-form-item>
					</el-col>                    
                    <el-col :span="12" v-for="(domain, index) in dynamicValidateForm.domains">
                        <el-form-item v-if="domain.value" :label="'手机号' + (parseInt(index)+2) + ':'" :label-width="formLabelWidth"> {{domain.value}} 
                        </el-form-item>
                    </el-col>
					<el-col :span="12"> 
						<el-form-item label="微信：" :label-width="formLabelWidth"> {{viewForm.wechat}}
						</el-form-item> 
					</el-col> 
                    <el-col :span="12"> 
                        <el-form-item v-if="viewForm.wechat2" label="微信2：" :label-width="formLabelWidth"> {{viewForm.wechat2}}
                        </el-form-item> 
                    </el-col> 
					<el-col :span="12"> 
						<el-form-item label="QQ：" :label-width="formLabelWidth"> {{viewForm.qq}} </el-form-item> 
					</el-col>
					<el-col :span="12"> 
						<el-form-item label="邮箱：" :label-width="formLabelWidth"> {{viewForm.email}}</el-form-item> 
					</el-col> 
					<el-col :span="12"> 
                        <el-form-item label="留言时间：" :label-width="formLabelWidth"> {{viewForm.messageTimeName}} </el-form-item> 
                    </el-col> 
                    <el-col :span="12"> 
                        <el-form-item label="留言重点：" :label-width="formLabelWidth"><span style="word-wrap: break-word;word-break: break-all;white-space: pre-wrap !important;">{{viewForm.messagePoint}}</span></el-form-item> 
                    </el-col> 
                    <el-col :span="12"> 
                        <el-form-item label="搜索词：" :label-width="formLabelWidth"><span style="word-wrap: break-word;word-break: break-all;white-space: pre-wrap !important;">{{viewForm.searchWord}}</span></el-form-item> 
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="词根：" :label-width="formLabelWidth"><span style="word-wrap: break-word;word-break: break-all;white-space: pre-wrap !important;">{{viewForm.rootWord}}</span></el-form-item>
                    </el-col>
                    <el-col :span="12">
						<el-form-item label="备注：" :label-width="formLabelWidth"><span style="word-wrap: break-word;word-break: break-all;white-space: pre-wrap !important;">{{viewForm.remark}}</span></el-form-item> 
					</el-col> 
				</el-row>
			</div>
			<div class="fs16 marginB10" style="padding-top: 20px;">资源信息</div>
			<div class="borderbox" style="padding:10px 0;">
				<el-row> 
                    <el-col :span="12"> 
                        <el-form-item label="年龄：" :label-width="formLabelWidth"> {{viewForm.age}}</el-form-item> 
                    </el-col> 
                    <el-col :span="12"> 
                        <el-form-item label="开店区域：" :label-width="formLabelWidth"><span v-if="viewForm.province">{{viewForm.province}}</span><span v-if="viewForm.province">&nbsp;&nbsp;{{viewForm.city}}</span><span v-if="viewForm.province">&nbsp;&nbsp;{{viewForm.district}}</span></el-form-item>
                    </el-col>
                    <el-col :span="12"> 
                        <el-form-item label="预约回访时间：" :label-width="formLabelWidth"> {{viewForm.reserveTimeName}}</el-form-item>
                    </el-col> 
					<el-col :span="12"> 
						<el-form-item label="资源类型："  :label-width="formLabelWidth">{{viewForm.typeName}}</el-form-item> 
					</el-col> 
					<el-col :span="12"> 
						<el-form-item label="资源类别：" :label-width="formLabelWidth"> {{viewForm.categoryName}}</el-form-item>
					</el-col> 
					<el-col :span="12"> 
						<el-form-item label="广告位：" :label-width="formLabelWidth"> {{viewForm.sourceTypeName}} </el-form-item> 
					</el-col> 
					<el-col :span="12"> 
						<el-form-item label="媒介：" :label-width="formLabelWidth"> {{viewForm.sourceName}} </el-form-item> 
					</el-col> 
					<el-col :span="12"> 
						<el-form-item label="资源项目(项目名称)：" :label-width="formLabelWidth">  {{viewForm.projectIdName}} </el-form-item> 
					</el-col> 
					<el-col :span="12"> 
						<el-form-item label="行业类别：" :label-width="formLabelWidth">  {{viewForm.industryCategoryName}} </el-form-item> 
					</el-col>					
					<el-col :span="12"> 
						<el-form-item label="账户名称：" :label-width="formLabelWidth"> {{viewForm.accountNameName}} </el-form-item> 
					</el-col>
					<el-col :span="24"> 
						<el-form-item label="URL地址：" :label-width="formLabelWidth"> {{viewForm.urlAddress}} </el-form-item> 
					</el-col> 
				</el-row>
			</div>
			<div class="padding20 f-tac">            
                <el-button type="primary" @click="submitForm('form')" :disabled="confirmBtnDisabled">提交</el-button>
                <el-button  @click="viewFormVisible=false">取 消</el-button>
            </div> 
		</el-form> 
	</el-dialog>
</div>
</body>
<!-- import Vue before Element -->
<div th:include="_footer_include :: #jsLib"></div>
<script th:inline="javascript" >
var clueCategoryList=[[${clueCategoryList}]];//资源类别集合
var projectList=[[${projectList}]];//项目集合
var adsenseList=[[${adsenseList}]];//广告位集合
var clueTypeList=[[${clueTypeList}]];//资源类型集合
var mediumList=[[${mediumList}]];//媒介集合
var industryCategoryList=[[${industryCategoryList}]];//行业类别集合
var accountNameList=[[${accountNameList}]];//账号名称集合
var ossSignatureUrl = [[${ossUrl}]];//上传文件地址
var optList = [[${optList}]];//优化资源类别
var notOptList = [[${notOptList}]];//非优化资源类别
var opt=[];
var notOpt=[];
if(optList){
	opt=optList.split(',');
}
if(notOptList){
	notOpt=notOptList.split(',');
}
  var addClueVM=new Vue({
        el: '#addCustomer',
        data: function() {
            return {
                isDisabled:true,//默认不可点击  
                sourceTypeDisabled:false,//广告位是否可选  
                projectDisabled:false,//项目是否可选  
                dialogFormVisible: false,//新增手机号
                viewFormVisible: false,//查看
                wechatVisible: false,//新增微信号
                chooseVisible: false,//选择模板
                buttonType: 'A',//添加手机号按钮形式
                deleteShow:false,//删除新增手机号输入框
                loading:false,
                confirmBtnDisabled:false,//提交按钮 是否禁用
                form: {  
                	cusName:'',
                	sex:'',
                	phone:'',
                	wechat:'',
                	wechat2:'',
                	wechatUrl:'',
                	qq:'',
                	email:'',
                	age:'',
                	reserveTime:'',
                	remark:'',
                	source:'',
                	sourceType:'',
                	type:'',
                	category:'',
                	projectId:'',
                	searchWord:'',
                    rootWord:'',
                	accountName:'',
                	urlAddress:'',
                	industryCategory:'',
                	messagePoint:'',
                	messageTime:'',
                  province:'',
                  city:'',
                  district:''
                },
                viewForm: {  
                	cusName:'',
                	sexName:'',
                	phone:'',
                	wechat:'',
                	wechat2:'',
                	qq:'',
                	email:'',
                	age:'',
                	reserveTimeName:'',
                	remark:'',
                	sourceName:'',
                	sourceTypeName:'',
                	typeName:'',
                	categoryName:'',
                	projectIdName:'',
                	searchWord:'',
                    rootWord:'',
                	accountNameName:'',
                	urlAddress:'',
                	industryCategoryName:'',
                	messagePoint:'',
                	messageTimeName:'',
                    province:'',
                    city:'',
                    district:''
                },
                wechatForm: {
                	wechat2:'',
                	wechatUrl:'',
                    fileList:[]
                },
                clueTemplateSearchForm: {
	        		name: '',
	        		clueProjectId: '',
	        		category: '',
	        		type: '',
	        		source: '',
	        		sourceType: ''
	            },
	            dataTable:[],
	            pager:{
	                total: 0,
	                currentPage: 1,
	                pageSize: 20,
	            },
                projectOptions:projectList,
	            sourceTypeOptions:adsenseList,
	            typeOptions:clueTypeList,
	            sourceOptions:mediumList,
	            categoryOptions:clueCategoryList,
	            industryCategoryOptions:industryCategoryList,
	            accountNameOptions:accountNameList,
                formLabelWidth: '140px',
                formLabelWidth1: '140px',
              provinceArr:[],
              cityArr:[],
              districtArr:[],
                rules:{
                    phone:[
                        { validator:function(rule,value,callback){
                            if(addClueVM.form.qq==""&&addClueVM.form.wechat==""&&addClueVM.wechatForm.wechat2==""&&addClueVM.form.email==""&&addClueVM.form.phone=="" && addClueVM.form.wechatUrl==""){
                                callback(new Error("至少填一项"));
                            }
                            // else{
                            //      callback();
                            // } 
                            // if(value){
                            //     if(/^[0-9]*$/.test(value) == false){
                            //         callback(new Error("请输入数字"));
                            //         return
                            //     }
                            //     if(value.length!==11){                                
                            //         callback(new Error("请输入11位数字"));
                            //         return
                            //     }
                            // }                            
                            callback();                             
                        }, trigger: 'blur'}
                    ],
                    wechat:[
                        { validator:function(rule,value,callback){
                            if(addClueVM.form.qq==""&&addClueVM.form.wechat==""&&addClueVM.wechatForm.wechat2==""&&addClueVM.form.email==""&&addClueVM.form.phone=="" && addClueVM.form.wechatUrl==""){
                                callback(new Error("至少填一项"));
                            }else{
                                 callback();
                            }                              
                        }, trigger: 'blur'}
                    ],
                    qq:[
                        { validator:function(rule,value,callback){
                            if(addClueVM.form.qq==""&&addClueVM.form.wechat==""&&addClueVM.wechatForm.wechat2==""&&addClueVM.form.email==""&&addClueVM.form.phone=="" && addClueVM.form.wechatUrl==""){
                                callback(new Error("至少填一项"));
                            }else{
                                 callback();
                            }                              
                        }, trigger: 'blur'}
                    ],
                    email:[
                        { validator:function(rule,value,callback){
                            if(addClueVM.form.qq==""&&addClueVM.form.wechat==""&&addClueVM.wechatForm.wechat2==""&&addClueVM.form.email==""&&addClueVM.form.phone=="" && addClueVM.form.wechatUrl==""){
                                callback(new Error("至少填一项"));
                            }else{
                                 callback();
                            }                              
                        }, trigger: 'blur'}
                    ],
                    age:[
                    	 { validator:function(rule,value,callback){
                              var reg =  /^[1-9]+[0-9]*]*$/ ;
                             if(value !=null && value !="null" && value !="" && !reg.test(value) ){
                                 callback(new Error("请输入正整数"));
                                 addClueVM.form.age =null;
                             }else{
                                 callback();
                             } 
                             
                         }, trigger: 'change'}
                    ],
                    source: [
                        { required: true, message: '媒介不能为空', trigger: 'change' }
                    ],
                    sourceType: [
                        { required: true, message: '广告位不能为空', trigger: 'change' }
                    ],
                    type: [
                        { required: true, message: '资源类型不能为空', trigger: 'change' }
                    ],
                    category: [
                        { required: true, message: '资源类别不能为空', trigger: 'change' }
                    ],
                     /* projectId: [
                         { required: true, message: '资源项目不能为空', trigger: 'change' }
                     ] */
                },
                dynamicValidateForm: {//新增手机号弹窗数据
                    domains: [{
                        value: ''
                    }]
                },
                optsex: [{
                    value: '1',
                    label: '男'
                }, {
                    value: '2',
                    label: '女'
                }],
                dialogForm: {
                    phoneNum:''
                },
                dialogRules:{
                    phoneNum: [
                        { required: true, message: '请输入手机号码', trigger: 'blur' }
                    ]
                },
                uploadOssHost:'',
                uploadParamData: {
                    key:'22',
                    policy:'',
                    OSSAccessKeyId:'',
                    success_action_status : '200', //让服务端返回200,不然，默认会返回204
                    signature:'', 
                    'x:params':'',
                    'realName':''
                 },
                 fileList:[],
                 limit:1,
                 ossUrl:ossSignatureUrl,
            }        	  
        },
        methods: {
            dateFormat(cellValue) {
                if (cellValue == undefined) {
                       return "";
                }
                return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");
            },
        	getUploadParam(){
                var signUrl = this.ossUrl+"?serviceType=aggregation";
                var param={};
                
                 axios.get(signUrl, param)
                .then(function (response) {
                   // console.info(response);
                    var respData= response.data;
                    var host = respData.host;
                    var params={};
                    var new_multipart_params = {
                            dir:respData.dir,
                            'policy': respData.policy,
                            'OSSAccessKeyId': respData.accessid,
                            'success_action_status' : '200', //让服务端返回200,不然，默认会返回204
                            'signature': respData.signature,
                            'x:params':params,//自定义编码，basse64编码后的字符串,
                            'realName':''
                   };
                  addClueVM.uploadParamData= new_multipart_params;
                  addClueVM.uploadOssHost = host;
                })
                .catch(function (error) {
                     console.log(error);
                });
            },
            selectFile(file, fileList){
                addClueVM.uploadParamData.key= addClueVM.uploadParamData.dir+addClueVM.random_string(10)+addClueVM.get_suffix(file.name),
                addClueVM.uploadParamData.realName= file.name
            },
            submitUpload(){
                //this.customUpload();
                this.$refs.refundApplyImgUpload.submit();
            },
            handlePreview(file){
             
            },
            handleRemove(file,fileList){
                this.fileList=[];
                this.wechatForm.fileList=[];
            },
            contains(a, obj) {
        	   var i = a.length;
        	       while (i--) {
        	           if (a[i] === obj) {
        	           return i;
        	        }
        	    }
        	    return false;
        	},
            handleExceed(files, fileList) {
             //this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            handleSuccess(response, file, fileList){
        	    console.info(fileList);
                console.info(addClueVM.fileList);
                var realName = file.name;
                var randomName = addClueVM.uploadParamData.key;
                var imgUrl =  addClueVM.uploadOssHost+"/"+randomName;
                this.wechatForm.wechatUrl=imgUrl;
                this.wechatForm.fileList.push(realName);
                this.fileList=[];
          	    this.wechatForm.fileList=[];
            },
            handleError(err, file, fileList){
                console.info(err);
            },
            handleBefore(file){
        	    var isTextComputer = file.type === 'image/png' || file.type==='image/jpeg';
                if(!isTextComputer){
                   this.fileList=[];
                   this.$message.error('文件格式错误');
                   return false;
                }
                if(file.size>2*1024*1024){
                   this.fileList=[];
                   this.$message.error('图片最大为2MB');
                   return false;
                }
            },
            random_string(len) {
                len = len || 32;
                var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
                var maxPos = chars.length;
                var pwd = '';
                for (i = 0; i < len; i++) {
                    pwd += chars.charAt(Math.floor(Math.random() * maxPos));
                }
                return pwd;
            },
            get_suffix(filename) {
                var pos = filename.lastIndexOf('.')
                suffix = ''
                if (pos != -1) {
                   suffix = filename.substring(pos);
                }
                return suffix;
            },
            openViewForm(form) {
                this.$refs[form].validate((valid) => {
                    if (valid) {
                        // 判断手机号是否重复开始
                        var domains=this.dynamicValidateForm.domains;
                        var phone=this.form.phone; 
                        var ary=[];   
                        console.log(domains)                  
                        for(var i=0;i<domains.length;i++){
                            // 判断弹框里的值是否与页面的手机号1重复
                            if(domains[i].value==phone&&phone!=""){
                                this.$message({
                                    message: '请不要提交重复手机号',
                                    type: 'warning'
                                });
                                return;
                            }
                          // 判断输入框里4个值是否重复(判断对象数组的value是否有重复值)
                          ary.push(domains[i].value);//把输入的手机号放入一个数组
                          var s = ary.join(",")+",";                            
                          console.log(ary)
                          for(var j=0;j<ary.length;j++) {
                              console.log(ary[j])
                              if(ary[j]!=""){
                                  if((","+s.replace(ary[j]+",","")).indexOf(","+ary[j]+",")>-1) {
                                      this.$message({
                                          message: '请不要提交重复手机号',
                                          type: 'warning'
                                      });
                                      return;
                                  }
                              }
                              
                          }   
                          // 如果输入的是非数字
                          if(/^[0-9]*$/.test(domains[i].value) == false){
                              this.$message({
                                  message: '请输入数字',
                                  type: 'warning'
                              });
                              return;
                          }

                        }
                        //判断手机号是否重复结束
                        //----资源基本信息---//
                        this.viewFormVisible=true;
                        this.viewForm=this.form;
                        //客户姓名
                        if(this.form.cusName){
                             this.viewForm.cusName=this.form.cusName;
                        }else{
                             this.viewForm.cusName='未知';
                        }
                        // 性别
                        if(this.form.sex){
                            if(this.form.sex=="1"){
                                this.viewForm.sexName="男";
                            }else if(this.form.sex=="2"){
                                this.viewForm.sexName="女";
                            }                            
                        }else{
                        	this.viewForm.sexName="";
                        }
                        //预约回访时间
                        if(this.form.reserveTime){
                             this.viewForm.reserveTimeName=addClueVM.dateFormat(this.form.reserveTime);
                        }else{
                        	this.viewForm.reserveTimeName="";
                        }
                        // 留言时间
                        if(this.form.messageTime){
                             this.viewForm.messageTimeName=addClueVM.dateFormat(this.form.messageTime);
                        }else{
                        	this.viewForm.messageTimeName="";
                        }
                        // 资源类型
                        if(this.form.type){
                            for(var i=0;i<clueTypeList.length;i++){
                                if(this.form.type==clueTypeList[i].value){
                                    this.viewForm.typeName=clueTypeList[i].name;
                                }
                            }
                        }
                        // 资源类别
                        if(this.form.category){
                            for(var i=0;i<clueCategoryList.length;i++){
                                if(this.form.category==clueCategoryList[i].value){
                                    this.viewForm.categoryName=clueCategoryList[i].name;
                                }
                            }
                        }              	
                        // 广告位
                    	if(this.form.sourceType){
                    		for(var i=0;i<adsenseList.length;i++){
     	                		if(this.form.sourceType==adsenseList[i].value){
     	                			this.viewForm.sourceTypeName=adsenseList[i].name;
     	                		}
     	                	}
                    	}
                        // 媒介
                        if(this.form.source){
                            for(var i=0;i<mediumList.length;i++){
                                if(this.form.source==mediumList[i].value){
                                    this.viewForm.sourceName=mediumList[i].name;
                                }
                            }
                        }                        
                        //资源项目
                    	if(this.form.projectId){
                    		for(var i=0;i<projectList.length;i++){
     	                		if(this.form.projectId==projectList[i].id){
     	                			this.viewForm.projectIdName=projectList[i].projectName;
     	                		}
     	                	}
                    	}else{
                    		this.viewForm.projectIdName="";
                    	}
                        // 行业类别
                        if(this.form.industryCategory){
                            for(var i=0;i<industryCategoryList.length;i++){
                                if(this.form.industryCategory==industryCategoryList[i].value){

                                    this.viewForm.industryCategoryName=industryCategoryList[i].name;
                                }
                            }
                        }else{
                    		this.viewForm.industryCategoryName="";
                    	}
                        // 账户名称
                        if(this.form.accountName){
                            for(var i=0;i<accountNameList.length;i++){
                                if(this.form.accountName==accountNameList[i].value){
                                    this.viewForm.accountNameName=accountNameList[i].name;
                                }
                            }
                        }else{
                    		this.viewForm.accountNameName="";
                    	}
                   	   
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            submitForm(form) {
                //----资源基本信息---//
            	 var param={};
             	//资源类型
            	 if(this.form.cusName){
	                 param.cusName=this.form.cusName;
                 }else{
	                 param.cusName='未知';
                 }
            	param.sex=this.form.sex;
            	param.phone=this.form.phone;
            	param.wechat=this.form.wechat;
            	param.wechat2=this.form.wechat2;
            	param.wechatCode=this.form.wechatUrl;
            	param.qq=this.form.qq;
            	param.email=this.form.email;
            	param.age=this.form.age;
            	param.province=this.form.province;
            	param.city=this.form.city;
                param.district=this.form.district;
            	param.reserveTime=this.form.reserveTime;
            	param.remark=this.form.remark;
            	param.source=this.form.source;
            	if(param.source){
            		for(var i=0;i<mediumList.length;i++){
	                		if(param.source==mediumList[i].value){
	                			param.sourceName=mediumList[i].name;
	                		}
	                	}
            	}
            	param.sourceType=this.form.sourceType;
            	param.type=this.form.type;
            	param.category=this.form.category;
            	param.projectId=this.form.projectId;
            	if(param.projectId){
            		for(var i=0;i<projectList.length;i++){
	                		if(param.projectId==projectList[i].id){
	                			param.projectName=projectList[i].projectName;
	                		}
	                	}
            	}
            	param.searchWord=this.form.searchWord;
                param.rootWord=this.form.rootWord;
            	param.messagePoint=this.form.messagePoint;
            	param.messageTime=this.form.messageTime;
            	param.accountName=this.form.accountName;
            	param.urlAddress=this.form.urlAddress;
            	param.industryCategory=this.form.industryCategory;
            	param.inputType=3;
           	    var phoneArr=this.dynamicValidateForm.domains;
        	    if(phoneArr.length>0){
        	     for(var i=0;i<phoneArr.length;i++){
        	    	 if(i==0)  {
        	    		 param.phone2=phoneArr[i].value;	 
        	         }
        	    	 if(i==1)  {
        	    		 param.phone3=phoneArr[i].value;	
        	         }
        	    	 if(i==2)  {
        	    		 param.phone4=phoneArr[i].value;	 
        	         }
        	    	 if(i==3)  {
        	    		 param.phone5=phoneArr[i].value;	 
        	         }
        	      }
        	    }
           	      addClueVM.confirmBtnDisabled=true;//禁用提交按钮
                  axios.post('/exetend/agendaTaskManager/createClue',param)
                  .then(function (response) {
                	  if(!response||!response.data){
                		  addClueVM.$message({
                                message: "接口调用失败",
                                type: 'error'
                            }); 
                            addClueVM.confirmBtnDisabled=false;
                            return ;
                	  }
                	  if(response.data.code!='0'){
                		  addClueVM.$message({
    	                        message:response.data.msg,
    	                        type: 'error',duration:2000,onClose:function(){
                                    addClueVM.confirmBtnDisabled=false;
    	                   	  		window.location.href="/exetend/agendaTaskManager/waitDistributResource"; 
    	                   	  		return;
    		        	   	}
                          }); 
                	  }else if(response.data.data>0){
                   	  	addClueVM.$message({message:'自动分发成功',type:'success',duration:2000,onClose:function(){
                            addClueVM.confirmBtnDisabled=false;
                   	  		window.location.href="/exetend/agendaTaskManager/waitDistributResource"; 
    	        	   		}});
                	  }else{
                   	  	addClueVM.$message({message:'自动分发失败',type:'error',duration:2000,onClose:function(){
                            addClueVM.confirmBtnDisabled=false;
                   	  		window.location.href="/exetend/agendaTaskManager/waitDistributResource"; 
    	        	   		}});
                	  }
                 });
            },
            rebackMV(){
          	    this.$confirm('编辑的资源未保存，是否离开?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
	            	  window.location.href="/exetend/agendaTaskManager/waitDistributResource"; 
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });          
                });
            },
            submitDialogForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) { 
                        var domains=this.dynamicValidateForm.domains;
                        var phone=this.form.phone; 
                        var ary=[];   
                        console.log(domains)                  
                        for(var i=0;i<domains.length;i++){
                            // 判断弹框里的值是否与页面的手机号1重复
                            if(domains[i].value==phone){
                                this.$message({
                                    message: '请不要提交重复手机号',
                                    type: 'warning'
                                });
                                return;
                            }
                          // 判断输入框里4个值是否重复(判断对象数组的value是否有重复值)
                          ary.push(domains[i].value);//把输入的手机号放入一个数组
                          var s = ary.join(",")+",";                            
                          console.log(ary)
                          for(var j=0;j<ary.length;j++) {
                              console.log(ary[j])
                              if(ary[j]!=""){
                                  if((","+s.replace(ary[j]+",","")).indexOf(","+ary[j]+",")>-1) {
                                      this.$message({
                                          message: '请不要提交重复手机号',
                                          type: 'warning'
                                      });
                                      return;
                                  }
                              }
                              
                          }   
                          // 如果输入的是非数字
                          if(/^[0-9]*$/.test(domains[i].value) == false){
                              this.$message({
                                  message: '请输入数字',
                                  type: 'warning'
                              });
                              return;
                          }

                        }
                        // 按钮变化
                        this.buttonType='B';
                        console.log('submit!!');
                        // 关闭弹窗
                        this.dialogFormVisible = false;
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
              });
            },
            categoryChange(value,clueProjectId) {
        	  	if(opt.indexOf(value)!=-1){
        	  		this.form.sourceType="1";
        	  		this.sourceTypeDisabled=true;
        	  		this.projectDisabled=true;
        	  		this.form.projectId= clueProjectId;
        	  	}else if(notOpt.indexOf(value)!=-1){
        	  		this.sourceTypeDisabled=false;
        	  		this.projectDisabled=false;
        	  	}
            },
            openWechat() {
        	  	this.wechatVisible = true
            	this.wechatForm.wechat2=this.form.wechat2;
            	this.wechatForm.wechatUrl=this.form.wechatUrl;
            },
            wechatSumbit() {
            	this.form.wechat2=this.wechatForm.wechat2;
            	this.form.wechatUrl=this.wechatForm.wechatUrl;
                if(this.wechatForm.wechat2!=""||this.wechatForm.wechatUrl!=""){
                    addClueVM.$message({ message: "提交成功", type: 'success' }); 
                    this.wechatVisible = false;
                }else{
                    addClueVM.$message({ message: "提交内容不能为空", type: 'error' }); 
                }            	
            },
            removeDomain(item) {
                var index = this.dynamicValidateForm.domains.indexOf(item);
                var itemLength = this.dynamicValidateForm.domains.length;                
                if (index !== -1) {
                    this.dynamicValidateForm.domains.splice(index, 1)
                }
                if(itemLength==2){
                    // 删除按钮不显示
                    this.deleteShow=false;
                }               
            },
            addDomain(item) {
                var itemLength = this.dynamicValidateForm.domains.length;
                if (itemLength<4) {
                    this.dynamicValidateForm.domains.push({
                        value: '',
                        key: Date.now()
                    });
                }else{
                    this.$message({
                        message: '最多添加5个手机号',
                        type: 'warning'
                    });
                }  
                if(itemLength>0){
                    // 显示删除按钮
                    this.deleteShow=true;                    
                }                              
            },
            clearDialog(){
                console.log('清空')

                // 1、数据清空
                var domains=this.dynamicValidateForm.domains
                for(var i=0;i<domains.length;i++){
                    domains[i].value=""
                }
                // 2、重置表单
                this.$refs['dynamicValidateForm'].resetFields()
                // 3、关闭弹窗
                this.dialogFormVisible = false;
                // 4、按钮变化
                this.buttonType='A';
            },
            number(){
    　　　     	this.form.phone=this.form.phone.replace(/[^\.\d]/g,'');
                this.form.phone=this.form.phone.replace('.','');
                // if(this.form.phone.length==11){
                if(this.form.phone!=""&&this.form.phone.length!=0){
                    this.isDisabled=false;
                }else{
                    this.isDisabled=true;
                }
        　  },
            phoneNumber(){
                var domains=this.dynamicValidateForm.domains;
                for(var i=0;i<domains.length;i++){
                    domains[i].value=domains[i].value.replace(/[^\.\d]/g,'');
                    domains[i].value=domains[i].value.replace('.','');
              	}    　　　                 
        　　},
            qqnumber(){
    　　　     	this.form.qq=this.form.qq.replace(/[^\.\d]/g,'');
                this.form.qq=this.form.qq.replace('.','');
    　　　 	},
    　　　 	chooseTemplate(){
                this.chooseVisible=true;
　　　     			this.pager.pageSize=20;
                this.pager.currentPage=1;
			　              this.clueTemplateSearchForm.name='';
			　              this.clueTemplateSearchForm.clueProjectId='';
			　              this.clueTemplateSearchForm.category='';
			　              this.clueTemplateSearchForm.type='';
			　              this.clueTemplateSearchForm.source='';
			　              this.clueTemplateSearchForm.sourceType='';
                this.searchTable();
    　　　 	},
　　　 	 	clickTemplate(row){
　　　     		this.chooseVisible=false;
　　　     		if(row.clueProjectId){
　                  			this.form.projectId=row.clueProjectId;
　　　     		}else{
　　　     			this.form.projectId='';
　　　     		}
　　　     		if(row.category){
　                  			this.form.category=row.category+'';
　　　     		}else{
　　　     			this.form.category='';
　　　     		}
　　　     		if(row.type){
　                 			this.form.type=row.type+'';
　　　     		}else{
　　　     			this.form.type='';
　　　     		}
　　　     		if(row.source){
　              			this.form.source=row.source+'';
　　　     		}else{
　　　     			this.form.source='';
　　　     		}
　　　     		if(row.sourceType){
　                  			this.form.sourceType=row.sourceType+'';
　　　     		}else{
　　　     			this.form.sourceType='';
　　　     		}
                if(row.searchWord){
                    this.form.searchWord=row.searchWord+'';
                }else{
                    this.form.searchWord='';
                }
                if(row.classification){
                    this.form.industryCategory=row.classification+'';
                }else{
                    this.form.industryCategory='';
                }
　　　     		this.categoryChange(this.form.category,row.clueProjectId);
            this.searchTable();
　　　 	 	},
　　　 	 	searchTable() {
                var param ={};
                
                param.pageSize = this.pager.pageSize;
                param.pageNum = this.pager.currentPage;
                param.name = this.clueTemplateSearchForm.name;
                param.clueProjectId = this.clueTemplateSearchForm.clueProjectId;
                param.category = this.clueTemplateSearchForm.category;
                param.type = this.clueTemplateSearchForm.type;
                param.source = this.clueTemplateSearchForm.source;
                param.sourceType = this.clueTemplateSearchForm.sourceType;
                console.info(param);
                axios.post('/aggregation/clueTemplate/list', param)
                .then(function (response) {
                        var result =  response.data;
                	    console.info(result);
                        var table=result.data;
                        addClueVM.dataTable= table.data;
                        addClueVM.pager.total =  table.total;
                        addClueVM.pager.currentPage = table.currentPage;
                        // 媒介转换
                        for(var i=0;i<table.data.length;i++){
                            if(table.data[i].source){
                                table.data[i].sourceName=addClueVM.transformSource(table.data[i].source);
                            }                        
                        }
                        // 广告位转换
                        for(var i=0;i<table.data.length;i++){
                            if(table.data[i].sourceType){ 
                                table.data[i].sourceTypeName=addClueVM.transformSourceType(table.data[i].sourceType);
                            }                        
                        }
                        // 资源类别转换
                        for(var i=0;i<table.data.length;i++){
                            if(table.data[i].category){
                                table.data[i].categoryName=addClueVM.transformCategory(table.data[i].category);
                            }                        
                        }
                        // 资源类型转换
                        for(var i=0;i<table.data.length;i++){
                            if(table.data[i].type){
                                table.data[i].typeName=addClueVM.transformType(table.data[i].type);
                            }                        
                        }

                    // 转换
                    for(var i=0;i<table.data.length;i++){
                        if(table.data[i].classification){
                            table.data[i].classificationName=addClueVM.transformClassification(table.data[i].classification);


                        }
                    }
                    console.log(table.data)
                })
                .catch(function (error) {
                     console.log(error);
                });
                
            },
            //开店区域联动方法
            currentProvince(selVal){
                param={};
                param.type="1";
                param.name=selVal;
                if(selVal) {
                  this.form.district = null;
                  this.form.city = null;
                  this.districtArr = null;
                  axios.post('/area/sysregion/querySysRegionByParam', param).then(function (response) {
                    addClueVM.cityArr = response.data.data.data;
                  });
                } else {
                  this.form.district = null;
                  this.form.city = null;
                  this.districtArr = null;
                  addClueVM.cityArr = null;
                }
            },
            currentCity(selVal){
                param={};
                param.type="2";
                param.name=selVal;
                if(selVal) {
                  this.form.district = null;
                  axios.post('/area/sysregion/querySysRegionByParam', param).then(function (response) {
                    addClueVM.districtArr = response.data.data.data;
                  });
                }else {
                  this.form.district = null;
                  addClueVM.districtArr = null;
                }
            },
    	 	//资源类别转换方法
            // transformCategory(row, column, cellValue, index) {
            transformCategory(cellValue) {
          	 var text="";
            	 if(clueCategoryList){
	                  for(var i=0;i<clueCategoryList.length;i++){
	                		if(cellValue==clueCategoryList[i].value){
	                			text=clueCategoryList[i].name;
	                		}
	                	}
          	  }
                return text;
             },
            transformClassification(cellValue) {
                var text="";
                if(industryCategoryList){
                    for(var i=0;i<industryCategoryList.length;i++){
                        if(cellValue==industryCategoryList[i].value){
                            text=industryCategoryList[i].name;
                        }
                    }
                }
                return text;
            },
            //资源类型转换方法
            // transformType(row, column, cellValue, index) {
            transformType(cellValue) {
          	   var text="";
            	   if(clueTypeList){
	                  for(var i=0;i<clueTypeList.length;i++){
	                		if(cellValue==clueTypeList[i].value){
	                			text=clueTypeList[i].name;
	                		}
	                	}
         	  		}
                  return text;
             },
            //广告位转换方法
            // transformSourceType(row, column, cellValue, index) {
            transformSourceType(cellValue) {
          	   var text="";
            	 if(adsenseList){
	                  for(var i=0;i<adsenseList.length;i++){
	                		if(cellValue==adsenseList[i].value){
	                			text=adsenseList[i].name;
	                		}
	                	}
        	  		}
                  return text;
            },
            //媒介转换方法
            // transformSource(row, column, cellValue, index) {
            transformSource(cellValue) {
          	   var text="";
            	 if(mediumList){
	                  for(var i=0;i<mediumList.length;i++){
	                		if(cellValue==mediumList[i].value){
	                			text=mediumList[i].name;
	                		}
	                	}
       	  		}
                  return text;
            },
            transformSource(cellValue) {
                var text="";
                if(mediumList){
                    for(var i=0;i<mediumList.length;i++){
                        if(cellValue==mediumList[i].value){
                            text=mediumList[i].name;
                        }
                    }
                }
                return text;
            },
        },
        mounted(){
            document.getElementById('addCustomer').style.display = 'block';
        },
        created(){
             //初始资源类别数据
        	this.getUploadParam();
            var  param={};
            param.type="0";
            axios.post('/area/sysregion/querySysRegionByParam',param).then(function (response) {
                addClueVM.provinceArr=response.data.data.data;
            });
        }
    })
</script>
</html>